<?php
class Users_model extends CI_Model {

    public function __construct()
    {
        $this->load->database();
    }
    public function get_user($username,$password)
    {
        //  $condition['userName']=$username;
        //   $condition['password']=$password;
        // $query = $this->db->where('condition',$condition);
        $this->db->where('userName',$username);
        $this->db->where('password',$password);
        $query= $this->db->get('ims_punch_admin_user');
        // echo $query;
        //  echo $query;
        return $query->row_array();
        //  return true;
    }
    public function get_users($id)
    {
        $this->db->where('id',$id);
        $query = $this->db->get('ims_punch_admin_user');
        //print_r($query);exit;
        return $query->row_array();
    }
    public function update_password($data)
    {
        if($this->db->where('id',$data['id'])){
            $this->db->replace('ims_punch_admin_user',$data);
        }
    }
    public function save_weixin($data){
        if($this->db->where('id',$data['id'])){
            $this->db->set('r_name', $data['r_name']);
            $this->db->set('r_id', $data['r_id']);
            $this->db->replace('ims_punch_admin_user',$data);
        }else{
            $this->db->set('r_name', $data['r_name']);
            $this->db->set('r_id', $data['r_id']);
            $this->db->insert('ims_punch_admin_user',$data);
        }
    }

}